Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw mermaid flowchart Version 1 #190

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

abjjabjj
Copy link
Contributor

@abjjabjj abjjabjj commented Nov 21, 2024

Try this in jupyter

from concrete.mermaid import FlowchartDirection
from concrete.operators import *
from concrete.projects import DAGNode, Project


project = Project()
nodes = [project.add_node(node) for node in [
    DAGNode("fee", "chat", Operator(), {"message": "Hello World!"}),
    DAGNode("fi", "ask_question", Developer(), {"context": "You pass butter."}),
    DAGNode("fo", "answer_question", Executive()),
    DAGNode("fum", "generate_summary", Executive()),
]]
edges = [
    project.add_edge("fee", "fo", "context"),
    project.add_edge("fi", "fo", "question"),
    project.add_edge("fee", "fum", "summary"),
    project.add_edge("fo", "fum", "implementation"),
]

print(project.draw_mermaid())

Paste to Mermaid Live Editor

See the magic

Needs tests but it's alive

  • Few styling options, i.e. title and direction of graph.
  • Few subgraph options, i.e. can set start and end nodes.
  • Implemented generic BFS and source/sink finders for directed graphs (note not acyclic constrained)
    • Hint hint means visualization should work on unfinished DAGProjects (I haven't actually tested this yet)

@abjjabjj
Copy link
Contributor Author

end_nodes functionality is bugged (but not feature breaking) because edge processing is done post-node processing

Copy link
Contributor Author

so edge case (get it) is for parent node of end node, it will process all the edges on that layer of the BFS instead of just the one connecting parent to end

Copy link
Contributor Author

actually there’s a bunch of other cases that will probably be buggy since there are no checks on end nodes

Copy link
Contributor Author

e.g. all the end nodes could be upstream of the start nodes if graph is a DAG

Copy link
Contributor Author

could change implementation to backtracking instead. I think that should solve the problems

@MichaelDeng03
Copy link
Contributor

I think your link to mermaid live editor is borked - it seems to be linking to github diffs

@MichaelDeng03
Copy link
Contributor

Otherwise, very neat!
Could you add a placeholder/templating to children nodes, it's not clear that answer_question can accept context/question.
image

Copy link
Contributor Author

abjjabjj commented Dec 4, 2024

added parameter info for all nodes now

Copy link
Contributor

kgang commented Dec 4, 2024

cool. beans.

Slack File: image.png

Copy link
Contributor Author

abjjabjj commented Dec 4, 2024

Hm. I was able to get the explicit function signatures when I ran it, not just args and kwargs

Copy link
Contributor

kgang commented Dec 4, 2024

:sadge:

Copy link
Contributor Author

abjjabjj commented Dec 4, 2024

For reference

Slack File: image.png

Copy link
Contributor

kgang commented Dec 4, 2024

are you able to repro what I got?

Copy link
Contributor Author

abjjabjj commented Dec 4, 2024

Not yet. It's something I saw earlier when I was pulling from the operator insurance and not the class

Copy link
Contributor

kgang commented Dec 5, 2024

if this isn't quite resolved we can push back our meeting @abjjabjj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants